<%-- 
    Document   : administracaoUsuarios
    Created on : 21/10/2010, 10:28:31
    Author     : Thiago
--%>

<%@page import="dao.UsuarioDAO"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="crypt.Crypt"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="bo.*"%>
<%@page import="beans.*"%>
<%@page import="autenticacao.Sessao"%>
<%

            String moduleId = "19";
            Crypt crypt = new Crypt();
            try {
                crypt.setKey(crypt.Decifragem((String) session.getAttribute("userPhrase")));
                String desafio = crypt.Cifragem(moduleId + "@" + ferramentas.DataHora.formatarDataHora(ferramentas.DataHora.retornarDataHoraAtual(), ferramentas.DataHora.DATE_TIME_FORMAT));
                if (!(new Sessao(session).validarSessao(desafio))) {
                    response.sendRedirect("/" + request.getContextPath());
                }
            } catch (Exception e) {
                response.sendRedirect("/" + request.getContextPath());
            }

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Gestor Operacional</title>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/style.css" type="text/css" rel="stylesheet"/>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/table.css" type="text/css" rel="stylesheet"/>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/anytime.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/jquery.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/anytime.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/anytimetz.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/table.js"></script>
    </head>
    <body>
        <table width="100%">
            <tr>
                <td>
                    <jsp:include page = "../menu.jsp" flush = "true"/>
                </td>
            </tr>

            <tr align="center">
                <td><br/><br/>
                    <input type="hidden" name="exibirGrafico" value="true">
                    <table border="1" cellspacing="0" width="430" bgcolor="#FFFFFF">
                        <tr>
                            <td width="105">
                                <div class="widget_tableDiv">
                                    <table id="myTable">
                                        <thead align="center">
                                            <tr>
                                                <td align="center"><b>Matrícula</b></td>
                                                <td align="center"><b>Nome</b></td>
                                                <td align="center"><b>Perfil</b></td>
                                                <td align="center"><b>Status</b></td>
                                            </tr>
                                        </thead>
                                        <tbody class="scrollingContent">
                                            <%
                                                        ArrayList<Usuario> ulist = null;
                                                        try {
                                                            ulist = new UsuarioDAO().recuperarUsuarios(null);
                                                        } catch(Exception e){
                                                            System.out.println(e.getMessage());
                                                        }
                                                        if ((ulist != null) && (!ulist.isEmpty())) {
                                                            for (int i = 0; i < ulist.size(); i++) {
                                                                out.println("<tr>");

                                                                out.println("<td align=\"center\"><a href=\"administracaoUsuarioEditar.jsp?matricula=" + ulist.get(i).getId() + "\">" + ulist.get(i).getId() + "</a></td>");

                                                                out.println("<td>&emsp;&emsp;" + ulist.get(i).getDescricao() + "</td>");

                                                                out.println("<td align=\"center\">" + ulist.get(i).getPerfil().getDescricao() + "</td>");

                                                                String aux = "";
                                                                if (ulist.get(i).getStatus() == Usuario.ATIVO) {
                                                                    aux = "Ativo";
                                                                } else {
                                                                    aux = "Inativo";
                                                                }
                                                                out.println("<td align=\"center\">" + aux + "</td>");

                                                                out.println("</tr>");
                                                            }
                                                        }
                                            %>
                                        </tbody>
                                    </table>
                                </div>
                                <script type="text/javascript">
                                    initTableWidget('myTable',600,350,Array('S','S','S','S'));
                                </script>
                            </td>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>
